﻿Public Class DALLEVEL
    Dim connect As CONDB = CONDB.NewConnection()
    'Dim connectlocal As conlocal = conlocal.NewConnection
    Dim PROVIDER_Check As New PROVIDERSCLASS

    Private Sub DRUGALLERGYLEVEL_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        SelectDatagridMASALEVEL()

        DesignForm(Me)
        DesignGrid(masalevelGrid)

        PROVIDER_Check.GETHOSEM(CInt(main.txtUserRequest.Text.Trim), Convert.ToString(Me.Tag))
    End Sub

    Private Sub SelectDatagridMASALEVEL()
        Dim objSelectDataMASALEVEL As New masalevel
        Dim MASALEVEL As DataTable
        MASALEVEL = connect.GetTable(objSelectDataMASALEVEL.selectMasalevel_)
        masalevelGrid.PrimaryGrid.DataSource = MASALEVEL
    End Sub

    Private Sub masalevelGrid_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles masalevelGrid.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow
        'f.TXT_CID.Text = grid.Cells.Item(2).Value
        ALEVELTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสความรุนแรงการแพ้ยา").Value()
        MASLVDESTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ความรุนแรงการแพ้ยา").Value()

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value() = True Then
            masalevelStatusChk.Checked = True
        Else
            masalevelStatusChk.Checked = False
        End If

        Dim objChkboxUpdate As New CLICKGRIDCHECKBOX
        objChkboxUpdate.clickChkboxUpdate("masalevel", CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value(), "STATUS", "ALEVEL", ALEVELTxt.Text)
    End Sub


    Private Sub addMasalevel_Click(sender As Object, e As EventArgs) Handles addMasalevel.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PADD_ = True Then
                If MASLVDESTxt.Text.ToString.Length > 0 Then
                    Dim objInsertData As New masalevel
                    objInsertData.MASLVDES_ = MASLVDESTxt.Text
                    objInsertData.STATUS_ = masalevelStatusChk.Checked
                    objInsertData.insertMasalevelData()

                    SelectDatagridMASALEVEL()

                    ALEVELTxt.Text = ""
                    MASLVDESTxt.Text = ""
                    masalevelStatusChk.Checked = False
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PADDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub editMasalevel_Click(sender As Object, e As EventArgs) Handles editMasalevel.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PUPD_ = True Then
                If ALEVELTxt.Text.ToString.Length > 0 And MASLVDESTxt.Text.ToString.Length > 0 Then
                    Dim editStat As Integer
                    editStat = MsgBox("ท่านต้องการแก้ไขข้อมูลความรุนแรงของการแพ้ยาดังกล่าวใช่หรือไม่", MsgBoxStyle.OkCancel)

                    If editStat = 1 Then
                        Dim objEditData As New masalevel
                        objEditData.ALEVEL_ = ALEVELTxt.Text
                        objEditData.MASLVDES_ = MASLVDESTxt.Text
                        objEditData.STATUS_ = masalevelStatusChk.Checked
                        objEditData.editMasalevelData()

                        SelectDatagridMASALEVEL()

                        ALEVELTxt.Text = ""
                        MASLVDESTxt.Text = ""
                        masalevelStatusChk.Checked = False
                    End If
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PUPDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub importExel_Click(sender As Object, e As EventArgs) Handles importExel.Click
        Dim nextform As New IMPORTEXCEL(Masalevel.Text)
        nextform.ShowDialog()
    End Sub

    Private Sub exportExcel_Click(sender As Object, e As EventArgs) Handles exportExcel.Click
        Dim nextform As New IMPORTEXCEL(Masalevel.Text)
        nextform.ShowDialog()
    End Sub
End Class